import math


def Pyramid(data: dict):
    """
    计算棱锥体，输入一个字典，返回一个字典
    :param data:字典
    {
    h: 棱锥体高度
    a：底面边长
    }

    :return res:字典
    {
    "Slope_height"：斜面高
    "Edge_length"：棱长
    "Lateral_area"：侧面积
    "Floor_area"：底面积
    "Total_area"：总面积
    "Volume"：体积
    }
    """
    if "h" in data and "a" in data:
        h = data["h"]
        a = data["a"]
        Slope_height = math.sqrt(h * h + (a / 2) * (a / 2))
        Edge_length = math.sqrt((a / 2) * (a / 2) + Slope_height * Slope_height)
        Lateral_area = 2 * Slope_height * a
        Floor_area = a * a
        Total_area = Lateral_area + Floor_area
        Volume = Floor_area * h / 3
    else:
        pass
    return {
        "Slope_height" : Slope_height,
        "Edge_length" : Edge_length,
        "Lateral_area" : Lateral_area,
        "Floor_area" : Floor_area,
        "Total_area" : Total_area,
        "Volume" : Volume
    }


def test():
    """
    测试函数
    :return:
    """
    data = {
        "h": 2,
        "a": 2
    }
    res = Pyramid(data)
    print(res)


test()
